package com.llmcu.source.mybatisplus.officialsample.quickstart;

import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.llmcu.source.mybatisplus.officialsample.quickstart.entity.SysUser;

/**
 * 测试id生成器
 */
public class TestIdGenerator {
    public static void main(String[] args) {
        SysUser sysUser = new SysUser().setName("123").setAge(12);
        // 直接使用DefaultIdentifierGenerator会有重复id的问题
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        System.out.println(new DefaultIdentifierGenerator().nextId(sysUser));
        // 使用工具类不会重复id
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
        System.out.println(IdWorker.getId());
    }
}
